package com.busionline.wotu.woochenandroid.presenter;

import com.busionline.wotu.baselibrary.mvp.BasePresenter;
import com.busionline.wotu.woochenandroid.bean.ArticleBean;
import com.busionline.wotu.woochenandroid.bean.BannerBean;
import com.busionline.wotu.woochenandroid.contract.HomeContract;
import com.busionline.wotu.woochenandroid.model.HomeModel;

import java.util.List;

/**
 *首页persenter
 *@author woochen123
 *@time 2018/5/15 14:56
 *@desc
 */
public class HomePresenter extends BasePresenter<HomeContract.IHomeView> implements HomeContract.IHomePersenter {
    HomeModel mHomeModel;

    public HomePresenter() {
        mHomeModel = new HomeModel();
    }

    @Override
    public void getHomeList() {
        mHomeModel.getHomeBanner(new HomeModel.CallBack<BannerBean>() {
            @Override
            public void onSuccess(List<BannerBean> result) {
                mView.showBannerList(result);
            }

            @Override
            public void fail(Throwable t) {
                mView.showError();
            }
        });

        mHomeModel.getHomeData(mView.getPage(),new HomeModel.CallBack<ArticleBean>() {

            @Override
            public void onSuccess(List<ArticleBean> result) {
                mView.showDataList(result);
            }

            @Override
            public void fail(Throwable t) {
                mView.showError();
            }
        });
    }
}
